<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Flat UI</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- Loading Bootstrap -->
    <link href="../assets/css/bootstrap.css" rel="stylesheet">

    <!-- Loading Flat UI -->
    <link href="../assets/css/flat-ui.css" rel="stylesheet">
    <link href="../assets/css/github.css" rel="stylesheet">
    <link rel="shortcut icon" href="../assets/images/favicon.ico">

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <![endif]-->
  </head>
  <body>


    <div class="container">
      <div class="demo-headline">
        <h1 class="demo-logo">Lettuce
          <small>Behaviour Driven Development for python</small></h1>
      </div>
      <div class="row">
        <div class="span4">
          <div class="sidebar-nav">
            <ul class="share mrl">
              <div class="btn btn-primary btn-block btn-large">
                <h3>Sections</h3>
              </div>
              
              <a class="btn btn-inverse btn-block btn-large"
       href="#language-support">
         language support
    </a>
  
    
      <a class="btn btn-inverse btn-block btn-large"
       href="#writing-features-in-a-specific-language">
         writing features in a specific language
    </a>
  
    
      <a class="btn btn-inverse btn-block btn-large"
       href="#english-example">
         english example
    </a>
  
    
      <a class="btn btn-inverse btn-block btn-large"
       href="#brazilian-portuguese-example">
         brazilian portuguese example
    </a>
  
    
  
    
      <a class="btn btn-inverse btn-block btn-large"
       href="#adding-support-to-other-languages">
         adding support to other languages
    </a>
  
    
      <a class="btn btn-inverse btn-block btn-large"
       href="#fetch-the-code">
         fetch the code
    </a>
  
    
      <a class="btn btn-inverse btn-block btn-large"
       href="#add-your-translation">
         add your translation
    </a>
  
    
  
    
  
              
            </ul>
          </div>
        </div>
        <div class="span8">
          <h1 id="language-support" name="language-support"><a href="#language-support">language support</a></h1>
<p>Lettuce currently supports two languages:</p>

<ul>
<li>  English</li>
<li>  Portuguese (Brazilian)</li>
</ul>

<p>Although it&#39;s only about writing tests since the current version does
output only in English.</p>
<h2 id="writing-features-in-a-specific-language" name="writing-features-in-a-specific-language"><a href="#writing-features-in-a-specific-language">writing features in a specific language</a></h2>
<p>You can tell lettuce the language of a feature file through adding a
comment in the first line of the file, using the following syntax:</p>
<div class="highlight"><pre name="language-support-example-1"><span class="c"># language: &lt;code&gt;</span>
</pre></div><h3 id="english-example" name="english-example"><a href="#english-example">english example</a></h3><div class="highlight"><pre name="language-support-example-2"><span class="c"># language: en</span>
<span class="n">Feature</span><span class="p">:</span> <span class="n">write</span> <span class="n">features</span> <span class="n">in</span> <span class="n">english</span>
   <span class="n">Scenario</span><span class="p">:</span> <span class="n">simple</span> <span class="n">scenario</span>
      <span class="n">Given</span> <span class="no">I</span> <span class="n">write</span> <span class="n">a</span> <span class="n">file</span> <span class="n">which</span> <span class="n">starts</span> <span class="n">with</span> <span class="s">"# language: en"</span>
      <span class="n">Then</span> <span class="n">it</span> <span class="n">must</span> <span class="n">be</span> <span class="n">parsed</span> <span class="n">with</span> <span class="n">proper</span> <span class="n">english</span> <span class="n">keywords</span>
</pre></div><h3 id="brazilian-portuguese-example" name="brazilian-portuguese-example"><a href="#brazilian-portuguese-example">brazilian portuguese example</a></h3><div class="highlight"><pre name="language-support-example-3"><span class="c"># language: pt-br</span>
<span class="n">Funcionalidade</span><span class="p">:</span> <span class="n">escrever</span> <span class="n">funcionalidades</span> <span class="n">em</span> <span class="n">portugu</span>&#234;<span class="n">s</span>
   <span class="n">Cen</span>&#225;<span class="n">rio</span><span class="p">:</span> <span class="n">cen</span>&#225;<span class="n">rio</span> <span class="n">simples</span>
      <span class="n">Dado</span> <span class="n">que</span> <span class="n">eu</span> <span class="n">crio</span> <span class="n">um</span> <span class="n">arquivo</span> <span class="n">que</span> <span class="n">come</span>&#231;<span class="n">a</span> <span class="n">com</span> <span class="s">"# language: pt-br"</span>
      <span class="n">Ent</span>&#227;<span class="n">o</span> <span class="n">ele</span> <span class="n">deve</span> <span class="n">ser</span> <span class="n">interpretado</span> <span class="n">com</span> <span class="n">as</span> <span class="n">devidas</span> <span class="n">palavras</span><span class="o">-</span><span class="n">chave</span> <span class="n">brasileiras</span>
</pre></div><h2 id="adding-support-to-other-languages" name="adding-support-to-other-languages"><a href="#adding-support-to-other-languages">adding support to other languages</a></h2>
<p>We love contribution, so if you want to bring lettuce to your native
language there is a single and simple way.</p>
<h3 id="fetch-the-code" name="fetch-the-code"><a href="#fetch-the-code">fetch the code</a></h3>
<p>First of all, you must have <a href="http://git-scm.com/" title="None">git</a> control version
installed in your machine.</p>

<p>Once you have it installed, grab the code with</p>
<div class="highlight"><pre name="language-support-example-4"><span class="n">user</span><span class="p">@</span><span class="n">machine</span><span class="p">:</span><span class="o">~</span>$ <span class="n">git</span> <span class="n">clone</span> <span class="n">git</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="p">.</span><span class="n">com</span><span class="o">/</span><span class="n">gabrielfalcao</span><span class="o">/</span><span class="n">lettuce</span><span class="p">.</span><span class="n">git</span>
</pre></div>
<p>And edit the file located at:</p>
<div class="highlight"><pre name="language-support-example-5"><span class="n">lettuce</span><span class="o">/</span><span class="n">languages</span><span class="p">.</span><span class="n">py</span>
</pre></div>
<p>And add a new dictionary entry for your native language.</p>

<p>Let&#39;s see the Brazilian Portuguese translation to exemplify.</p>
<div class="highlight"><pre name="language-support-example-6"><span class="n">LANGUAGES</span> <span class="p">=</span> <span class="p">{</span>
    <span class="s">'pt-br'</span><span class="p">:</span> <span class="p">{</span>
        <span class="s">'examples'</span><span class="p">:</span> <span class="n">u</span><span class="o">'</span><span class="n">Exemplos</span><span class="o">|</span><span class="n">Cen</span>&#225;<span class="n">rios</span><span class="o">'</span><span class="p">,</span>
        <span class="s">'feature'</span><span class="p">:</span> <span class="n">u</span><span class="o">'</span><span class="n">Funcionalidade</span><span class="o">'</span><span class="p">,</span>
        <span class="s">'name'</span><span class="p">:</span> <span class="n">u</span><span class="o">'</span><span class="n">Portuguese</span><span class="o">'</span><span class="p">,</span>
        <span class="s">'native'</span><span class="p">:</span> <span class="n">u</span><span class="o">'</span><span class="n">Portugu</span>&#234;<span class="n">s</span><span class="o">'</span><span class="p">,</span>
        <span class="s">'scenario'</span><span class="p">:</span> <span class="n">u</span><span class="o">'</span><span class="n">Cen</span>&#225;<span class="n">rio</span><span class="o">|</span><span class="n">Cenario</span><span class="o">'</span><span class="p">,</span>
        <span class="s">'scenario_outline'</span><span class="p">:</span> <span class="n">u</span><span class="o">'</span><span class="n">Esquema</span> <span class="n">do</span> <span class="n">Cen</span>&#225;<span class="n">rio</span><span class="o">|</span><span class="n">Esquema</span> <span class="n">do</span> <span class="n">Cenario</span><span class="o">'</span><span class="p">,</span>
        <span class="s">'scenario_separator'</span><span class="p">:</span> <span class="n">u</span><span class="o">'</span><span class="p">(</span><span class="n">Esquema</span> <span class="n">do</span> <span class="n">Cen</span>&#225;<span class="n">rio</span><span class="o">|</span><span class="n">Esquema</span> <span class="n">do</span> <span class="n">Cenario</span><span class="o">|</span><span class="n">Cenario</span><span class="o">|</span><span class="n">Cen</span>&#225;<span class="n">rio</span><span class="p">)</span><span class="o">'</span><span class="p">,</span>
    <span class="p">},</span>
<span class="p">}</span>
</pre></div>
<p>The key of the dict will be used as identifier for the comment
<code># language: identifier</code> at feature files.</p>

<p>The value must be a dict, where the keys are canonical representation of
keywords (string), and the values must be a pipe-separated string with
translation possibilities.</p>

<p>It allows different translations for the same keyword in the current
language, which offers many possibilities for different semantical
cases.</p>

<p>For example, when using scenario outlines, it can be semantically nicer
to write:</p>
<div class="highlight"><pre name="language-support-example-7"><span class="n">Scenarios</span><span class="p">:</span>
   <span class="o">|</span> <span class="n">name</span> <span class="o">|</span> <span class="n">age</span> <span class="o">|</span>
   <span class="o">|</span> <span class="n">John</span> <span class="o">|</span> 22  <span class="o">|</span>
   <span class="o">|</span> <span class="n">Mary</span> <span class="o">|</span> 53  <span class="o">|</span>
</pre></div>
<p>Instead of:</p>
<div class="highlight"><pre name="language-support-example-8"><span class="n">Examples</span><span class="p">:</span>
   <span class="o">|</span> <span class="n">name</span> <span class="o">|</span> <span class="n">age</span> <span class="o">|</span>
   <span class="o">|</span> <span class="n">John</span> <span class="o">|</span> 22  <span class="o">|</span>
   <span class="o">|</span> <span class="n">Mary</span> <span class="o">|</span> 53  <span class="o">|</span>
</pre></div><h3 id="add-your-translation" name="add-your-translation"><a href="#add-your-translation">add your translation</a></h3>
<p>Now you can add your own language to lettuce, save the <code>languages.py</code>
file and commit in the source control with.</p>

<p>For example, let&#39;s suppose that you&#39;ve added Spanish support:</p>
<div class="highlight"><pre name="language-support-example-9"><span class="n">user</span><span class="p">@</span><span class="n">machine</span><span class="p">:</span><span class="o">~/</span><span class="n">lettuce</span>$ <span class="n">git</span> <span class="n">commit</span> <span class="n">lettuce</span><span class="o">/</span><span class="n">languages</span><span class="p">.</span><span class="n">py</span> <span class="o">-</span><span class="n">m</span> <span class="s">'adding translation for spanish'</span>
</pre></div>
<p>Generate a patch:</p>
<div class="highlight"><pre name="language-support-example-10"><span class="n">user</span><span class="p">@</span><span class="n">machine</span><span class="p">:</span><span class="o">~/</span><span class="n">lettuce</span>$ <span class="n">git</span> <span class="n">format</span> <span class="n">patch</span> <span class="n">HEAD</span>^1
</pre></div>
<p>And send to lettuce&#39;s
<a href="http://github.com/gabrielfalcao/lettuce/issues" title="None">ticket</a> tracker as a
<a href="http://gist.github.com/" title="None">gist</a> or something like it.</p>

        </div>
      </div>
    </div> <!-- /container -->

    <footer>
      <div class="container">
        <div class="row">
          <div class="span7">
            <h3 class="footer-title">Lettuce</h3>
            <p>Lettuce is maintained by gabrielfalcao. <br />
              This documentation was generated automatically by <a href="http://octomarks.io/gabrielfalcao/markment">Markment</a>.
            </p>
            <p>
              This theme was written by Gabriel Falcão using the <a href="http://designmodo.github.io/Flat-UI/">Flat-UI</a> library by
              <a class="footer-brand" href="http://designmodo.com" target="_blank">
                <img src="../assets/images/footer/logo.png" alt="Designmodo.com">
              </a>
            </p>
          </div> <!-- /span8 -->

          <div class="span5">
            <div class="footer-banner">
              <h3 class="footer-title">Table of contents</h3>
              <ul>
                 
                <li>
                  <a href="../contents.html">
                        contents.md
                  </a>
                </li>
                 
                <li>
                  <a href="../index.html">
                        index.md
                  </a>
                </li>
                 
                <li>
                  <a href="../dev/documentation.html">
                        documentation.md
                  </a>
                </li>
                 
                <li>
                  <a href="../dev/index.html">
                        index.md
                  </a>
                </li>
                 
                <li>
                  <a href="../dev/install-debian-squeeze.html">
                        install-debian-squeeze.md
                  </a>
                </li>
                 
                <li>
                  <a href="../dev/install.html">
                        install.md
                  </a>
                </li>
                 
                <li>
                  <a href="../dev/testing.html">
                        testing.md
                  </a>
                </li>
                 
                <li>
                  <a href="../intro/install.html">
                        install.md
                  </a>
                </li>
                 
                <li>
                  <a href="../intro/overview.html">
                        overview.md
                  </a>
                </li>
                 
                <li>
                  <a href="../intro/wtf.html">
                        wtf.md
                  </a>
                </li>
                 
                <li>
                  <a href="../recipes/django-lxml.html">
                        django-lxml.md
                  </a>
                </li>
                 
                <li>
                  <a href="../recipes/nose.html">
                        nose.md
                  </a>
                </li>
                 
                <li>
                  <a href="./cli.html">
                        cli.md
                  </a>
                </li>
                 
                <li>
                  <a href="./features.html">
                        features.md
                  </a>
                </li>
                 
                <li>
                  <a href="./languages.html">
                        languages.md
                  </a>
                </li>
                 
                <li>
                  <a href="./terrain.html">
                        terrain.md
                  </a>
                </li>
                 
                <li>
                  <a href="../tutorial/django.html">
                        django.md
                  </a>
                </li>
                 
                <li>
                  <a href="../tutorial/multiline.html">
                        multiline.md
                  </a>
                </li>
                 
                <li>
                  <a href="../tutorial/scenario-outlines.html">
                        scenario-outlines.md
                  </a>
                </li>
                 
                <li>
                  <a href="../tutorial/simple.html">
                        simple.md
                  </a>
                </li>
                 
                <li>
                  <a href="../tutorial/steps-from-step-definitions.html">
                        steps-from-step-definitions.md
                  </a>
                </li>
                 
                <li>
                  <a href="../tutorial/tables.html">
                        tables.md
                  </a>
                </li>
                 
              </ul>
            </div>
          </div>
        </div>
      </div>
    </footer>
  </body>
</html>